package com.ludomancy.hugealien;

import java.awt.Graphics;
import java.awt.Rectangle;
import com.ludomancy.gamelib.ImageAnimation;
import com.ludomancy.gamelib.Randomizer;

public class Star extends BasicEntity
{
	private ImageAnimation anim;
	
	public static final int TYPE_GRAY = 0;
	public static final int TYPE_GOLD = 1;
	public static final int TYPE_PURPLE = 2;
	
	public Star(Soul s1, Soul s2, int type)
	{
		// create a sequence for the intensities
		int intensity = Randomizer.getRandom(2,4);
		int seq[] = new int[intensity*2];
		for (int i = 0; i < intensity; i++)
		{
			seq[i] = i + type * 4;
			seq[seq.length - 1 - i] = i + type * 4;
		}
		anim = ImageAnimation.create("star.png", 16, 16, 3);
		anim.setSequence(seq);
		anim.looping = true;
		anim.play();
	}
	
	public Rectangle area()
	{
		int w = anim.strip.frameWidth;
		int h = anim.strip.frameHeight;
		return new Rectangle(x-w/2,y-h/2, w, h);
	}
	
	public void paint(Graphics g, int px, int py)
	{
		anim.paintCurrentFrame(g, area().x, area().y);
	}
	
	public void update()
	{
		anim.update();
	}
}
